package only.my.railgunys.shooting;

import only.my.railgunys.artifact.ArtifactSuitEffect;
import only.my.railgunys.artifact.imp.*;
import only.my.railgunys.bean.Character;
import only.my.railgunys.bean.Enemy;
import only.my.railgunys.bean.Weapon;
import only.my.railgunys.repository.SceneRepository;
import only.my.railgunys.utils.ArtifactSetUtils;
import only.my.railgunys.utils.Crutch;
import only.my.railgunys.utils.FightUtils;
import only.my.railgunys.weapon.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

import static only.my.railgunys.preparation.SingleData.getSceneList;
import static only.my.railgunys.utils.Crutch.instructorBennett;
import static only.my.railgunys.utils.FightUtils.*;

@Component
public class Yoimiya {
    @Autowired
    SceneRepository sceneRepository;

    public void initYoimiyaData(){
        Weapon thunderingPulse = new ThunderingPulse(1);
        calc(thunderingPulse);
        Weapon rust = new Rust(5);
        calc(rust);
        Weapon amosBow = new AmosBow(1);
        calc(amosBow);
    }

    public static Character getNormal90() {
        Character yoimiya = initYoimiya90Shooting();
        Enemy enemy = FightUtils.initNormal90(4);
        yoimiya.setEnemy(enemy);
        yoimiya.setSkillDmg(41.01694);
        Crutch.doubleFireTeam(yoimiya);
        return yoimiya;
    }

    private void calc(Weapon harpoon) {
        ArtifactSuitEffect gladiator = new Gladiator();
        ArtifactSuitEffect shimenawa = new Shimenawa();
        CrimsonWitch crimsonWitch = new CrimsonWitch();

        Character yoimiya = Yoimiya.getNormal90();
        instructorBennett(yoimiya);
        List<Character> characters2 = FightUtils.calcSuitIncrease(yoimiya, harpoon, shimenawa::setEffect2Piece, shimenawa::setEffect4Piece);
        sceneRepository.saveAll(getSceneList(characters2));

        Character yoimiya22 = Yoimiya.getNormal90();
        instructorBennett(yoimiya22);
        List<Character> characters3 = FightUtils.calcSuitIncrease(yoimiya22, harpoon, gladiator::setEffect2Piece, shimenawa::setEffect2Piece);
        sceneRepository.saveAll(getSceneList(characters3));

        Character yoimiyac2w2 = Yoimiya.getNormal90();
        instructorBennett(yoimiyac2w2);
        List<Character> characters4 = FightUtils.calcSuitIncrease(yoimiyac2w2, harpoon, crimsonWitch::setEffect2Piece, shimenawa::setEffect2Piece);
        sceneRepository.saveAll(getSceneList(characters4));
    }

    public static List<Character> with25wordsShimenawa4(Character character) {
        List<Character> temp = ArtifactSetUtils.mainStatRollEnhance(character);

        List<Character> characters = ArtifactSetUtils.possibleStatRollEnhance(temp,25);

        ArtifactSuitEffect shimenawa = new Shimenawa();
        characters.parallelStream()
                .map(shimenawa::setEffect2Piece)
                .map(shimenawa::setEffect4Piece)
                .forEach(FightUtils::calcTotalDmg);

        return characters;
    }
    public static List<Character> with25wordsRetracing4(Character character) {
        List<Character> temp = ArtifactSetUtils.mainStatRollEnhance(character);

        List<Character> characters = ArtifactSetUtils.possibleStatRollEnhance(temp,25);

        ArtifactSuitEffect retracingBolide = new RetracingBolide();
        characters.parallelStream()
                .map(retracingBolide::setEffect2Piece)
                .map(retracingBolide::setEffect4Piece)
                .forEach(FightUtils::calcTotalDmg);
        return characters;
    }
    public static List<Character> with25wordsShimenawa2Gladiator2(Character character) {
        List<Character> temp = ArtifactSetUtils.mainStatRollEnhance(character);
        List<Character> characters = ArtifactSetUtils.possibleStatRollEnhance(temp,25);

        ArtifactSuitEffect shimenawa = new Shimenawa();
        ArtifactSuitEffect gladiator = new Gladiator();
        characters.parallelStream()
                .map(shimenawa::setEffect2Piece)
                .map(gladiator::setEffect2Piece)
                .forEach(FightUtils::calcTotalDmg);
        return characters;
    }
    public Character init90YoimiyaThundering(){

        Character yoimiya90Shooting = initYoimiya90Shooting();
        Enemy enemy = initNormal90(1);
        yoimiya90Shooting.setEnemy(enemy);
        yoimiya90Shooting.setSkillDmg(41.01694);
        Crutch.doubleFireTeam(yoimiya90Shooting);

        ThunderingPulse thunderingPulse = new ThunderingPulse(1);
        thunderingPulse.mainStatEnhance(yoimiya90Shooting);
        thunderingPulse.subStatEnhance(yoimiya90Shooting);
        thunderingPulse.specialAbility(yoimiya90Shooting);
        return yoimiya90Shooting;
    }

    public Character init90YoimiyaRust(){

        Character yoimiya90Shooting = initYoimiya90Shooting();
        Enemy enemy = initNormal90(1);
        yoimiya90Shooting.setEnemy(enemy);
        yoimiya90Shooting.setSkillDmg(41.01694);
        Crutch.doubleFireTeam(yoimiya90Shooting);

        Weapon rust = new Rust(5);
        rust.mainStatEnhance(yoimiya90Shooting);
        rust.subStatEnhance(yoimiya90Shooting);
        rust.specialAbility(yoimiya90Shooting);
        return yoimiya90Shooting;
    }
    public Character init90YoimiyaAmos(){

        Character yoimiya90Shooting = initYoimiya90Shooting();
        Enemy enemy = initNormal90(4);
        yoimiya90Shooting.setEnemy(enemy);
        yoimiya90Shooting.setSkillDmg(41.01694);
        Crutch.doubleFireTeam(yoimiya90Shooting);

        AmosBow amosBow = new AmosBow(1);
        amosBow.mainStatEnhance(yoimiya90Shooting);
        amosBow.subStatEnhance(yoimiya90Shooting);
        amosBow.specialAbility(yoimiya90Shooting);

        return yoimiya90Shooting;
    }
    public  static Character initYoimiya90Shooting(){
        Character yoimiya = new Character();

        yoimiya.setHp(10164D);
        yoimiya.setAtk(323D);
        yoimiya.setRole(2);
        yoimiya.setCritDmg(50D);
        yoimiya.setCritRate(24.2D);
        yoimiya.setLevel(90);
        yoimiya.setDescription("90级霄宫");
        yoimiya.setIncrease(20D); //天赋20火伤
        yoimiya.setAtkUseful(true);
        yoimiya.setCritRateUseful(true);
        yoimiya.setElementDmgUseful(true);
        return yoimiya;
    }
}
